package com.wang.interview.threads;

/**
 * @author: wang
 * @date: 2021/7/25 16:48
 * @description:
 */
public class ThreadDeadLockTest {
}

// 在只有一个线程的时候，一个线程调用另一个线程且等待其执行结果时，就会发生死锁
/*public class AboutThread {
    ExecutorService executorService = Executors.newSingleThreadExecutor();

    public static void main(String[] args) {
        AboutThread aboutThread = new AboutThread();
        aboutThread.threadDeadLock();
    }

    public void threadDeadLock() {
        Future taskOne = executorService.submit(new TaskOne());
        try {
            System.out.printf(taskOne.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }

    public class TaskOne implements Callable {
        @Override
        public Object call() throws Exception {
            Future taskTow = executorService.submit(new TaskTwo());
            return "TaskOne" + taskTow.get();
        }
    }

    public class TaskTwo implements Callable {
        @Override
        public Object call() throws Exception {
            return "TaskTwo";
        }
    }
}*/